
##################################################
# Predictive validity: Three-Way Interactions (CA) 
##################################################

# 1. Activism  =================================================================
# Interaction model
mActivCA<-lm(activism ~ 
             age + education_num + sex_fem  + ideology + # demographics
             InterestedNum+
             InterestedNum*pos_id_mean*neg_id_mean , # 3 way interaction
           data = data_CA_cov_std) # data frame with only interested 

# Create interaction data frame
inter_activCA <- emmip(mActivCA,neg_id_mean~pos_id_mean~InterestedNum,at=list, CIs=TRUE, PIs=TRUE, plotit = FALSE)
inter_activCA$combination<-paste(inter_activCA$xvar,inter_activCA$tvar, sep = " ") # combine conditions

inter_activ_keepCA<-inter_activCA%>%
  dplyr::select(., combination,yvar)%>%
  pivot_wider(names_from = "combination", values_from = "yvar")
inter_activ_keepCA$DV<-"Political activism (H1)"


# 2. News Consumption ========================================================
# Interaction model
mNewsCA<-lm(pol_news_con ~ 
             age + education_num + sex_fem  + ideology + # demographics
             InterestedNum+
             InterestedNum*pos_id_mean*neg_id_mean , # 3 way interaction
           data = data_CA_cov_std) # data frame with only interested 

# Create interaction data frame
inter_newsCA <- emmip(mNewsCA,neg_id_mean~pos_id_mean~InterestedNum,at=list, CIs=TRUE, PIs=TRUE, plotit = FALSE)
inter_newsCA$combination<-paste(inter_newsCA$xvar,inter_newsCA$tvar, sep = " ") # combine conditions

inter_news_keepCA<-inter_newsCA%>%
  dplyr::select(., combination,yvar)%>%
  pivot_wider(names_from = "combination", values_from = "yvar")
inter_news_keepCA$DV<-"News consumption (H2b)"

# 3. News openness ===================================================
# Interaction model
mOpenCA<-lm(news_openness ~ 
            age + education_num + sex_fem  + ideology + # demographics
            InterestedNum+
            InterestedNum*pos_id_mean*neg_id_mean , # 3 way interaction
          data = data_CA_cov_std) # data frame with only interested 

# Create interaction data frame
inter_openCA <- emmip(mOpenCA,neg_id_mean~pos_id_mean~InterestedNum,at=list, CIs=TRUE, PIs=TRUE, plotit = FALSE)
inter_openCA$combination<-paste(inter_openCA$xvar,inter_openCA$tvar, sep = " ") # combine conditions

inter_open_keepCA<-inter_openCA%>%
  dplyr::select(., combination,yvar)%>%
  pivot_wider(names_from = "combination", values_from = "yvar")
inter_open_keepCA$DV<-"News openness (H4b; H4d)"


# 4. Political Efficacy ======================================================
# Interaction model
mEffCA<-lm(pol_efficacy ~ 
            age + education_num + sex_fem  + ideology + # demographics
            InterestedNum+
            InterestedNum*pos_id_mean*neg_id_mean , # 3 way interaction
          data = data_CA_cov_std) # data frame with only interested 

# Create interaction data frame
inter_effCA <- emmip(mEffCA,neg_id_mean~pos_id_mean~InterestedNum,at=list, CIs=TRUE, PIs=TRUE, plotit = FALSE)
inter_effCA$combination<-paste(inter_effCA$xvar,inter_effCA$tvar, sep = " ") # combine conditions

inter_eff_keepCA<-inter_effCA%>%
  dplyr::select(., combination,yvar)%>%
  pivot_wider(names_from = "combination", values_from = "yvar")
inter_eff_keepCA$DV<-"Political efficacy (H2a; H3)"


# 5. Confidence in Knowledge =================================================
# Interaction model
mConfCA<-lm(pol_confidence ~ 
           age + education_num + sex_fem  + ideology + # demographics
           InterestedNum+
           InterestedNum*pos_id_mean*neg_id_mean , # 3 way interaction
         data = data_CA_cov_std) # data frame with only interested 

# Create interaction data frame
inter_confCA <- emmip(mConfCA,neg_id_mean~pos_id_mean~InterestedNum,at=list, CIs=TRUE, PIs=TRUE, plotit = FALSE)
inter_confCA$combination<-paste(inter_confCA$xvar,inter_confCA$tvar, sep = " ") # combine conditions

inter_conf_keepCA<-inter_confCA%>%
  dplyr::select(., combination,yvar)%>%
  pivot_wider(names_from = "combination", values_from = "yvar")
inter_conf_keepCA$DV<-"Confidence in knowledge (H2c)"


# 6. Political Knowledge ==============================================================
# Interaction model
mKnowCA<-lm(pol_knowledge ~ 
            age + education_num + sex_fem  + ideology + # demographics
            InterestedNum+
            InterestedNum*pos_id_mean*neg_id_mean , # 3 way interaction
          data = data_CA_cov_std) # data frame with only interested 

# Create interaction data frame
inter_knowCA <- emmip(mKnowCA,neg_id_mean~pos_id_mean~InterestedNum,at=list, CIs=TRUE, PIs=TRUE, plotit = FALSE)
inter_knowCA$combination<-paste(inter_knowCA$xvar,inter_knowCA$tvar, sep = " ") # combine conditions

inter_know_keepCA<-inter_knowCA%>%
  dplyr::select(., combination,yvar)%>%
  pivot_wider(names_from = "combination", values_from = "yvar")
inter_know_keepCA$DV<-"Political knowledge (H4a; H4c)"

# Regression table with all six models ----
stargazer(mActivCA, mEffCA, mNewsCA, mOpenCA, mConfCA, mKnowCA,
          type="latex", digits = 2, digits.extra = 0, summary = F, style = "apsr",omit.stat = "f")